package com.rex.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by frt on 2017/11/9.
 *
 */
@Controller
public class IndexController {
    @ModelAttribute("testStr")
    public String testStr(){
        return "Hello Thymeleaf";
    }


    @RequestMapping(value = "/index")
    public String index(){
        return "index";
    }

    @RequestMapping(value = "/hello", name = "hello")
    public void hello(ModelMap modelMap){
        modelMap.put("hello", "hello world");
    }

    @RequestMapping(value = "/helloList")
    public List<String> helloList(String a, String b){
        List<String> list = new ArrayList<>();
        list.add(a);
        list.add(b);
        list.add("c");
        return list;
    }
}
